class Solution {
public:
    int wiggleMaxLength(vector<int>& nums) {
        if (nums.empty()) return 0;
        int left = 0;
        int right = 0;
		//left right 记录左右位置跳过相同值
        int count = 0;
        for (int i = 0; i < nums.size() - 1; ++i) {
            right = nums[i + 1] - nums[i];
            if (right == 0) continue;
            if (right * left <= 0) {
                count++;
                left = right;
            }
        }
        return count + 1;
    }
};